import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  OneToMany,
  ManyToOne,
  JoinColumn,
} from "typeorm";
import { ManualTimestamp } from "../decorators/manual-timestamp.decorator";
import { CharacterGemInventoryEntity } from "./character-gem-inventory.entity";
import { EquipmentGemSocketEntity } from "./equipment-gem-socket.entity";
import { GemAttributeEntity } from "./gem-attribute.entity";

// 宝石属性接口
export interface GemAttribute {
  type: number;
  name: string;
  maxValue: number;
}

@Entity("gem_base")
@ManualTimestamp()
export class GemBaseEntity {
  @PrimaryGeneratedColumn()
  id!: number;

  @Column("varchar", { length: 50, comment: "宝石名称" })
  name!: string;

  @Column("varchar", { length: 100, nullable: true, comment: "宝石图片" })
  image!: string;

  @Column("int", { name: "max_level", default: 10, comment: "最大等级" })
  maxLevel!: number;

  @Column("text", {
    name: "attribute_id",
    nullable: true,
    comment: "宝石属性ID数组",
  })
  attributeId!: string;

  @Column("datetime", { name: "created_at", comment: "创建时间" })
  created_at!: Date;

  @Column("datetime", {
    name: "updated_at",
    nullable: true,
    comment: "更新时间",
  })
  updated_at!: Date | null;

  // 关联关系

  @OneToMany(
    () => CharacterGemInventoryEntity,
    (inventory) => inventory.gemBase
  )
  inventories!: CharacterGemInventoryEntity[];

  // @OneToMany(() => EquipmentGemSocketEntity, (socket) => socket.gemBase)
  // sockets!: EquipmentGemSocketEntity[];
}
